#include <iostream>
#include <string>
using namespace std;
int main()
{
int c1o,c1z,c2o,c2z,c3o,c3z,c4o,c4z;
string s1;
string s;
cin>>s;
for(char c:s){
    if(c=='(') c1o++;
    if(c==')') c1z++;
    if(c=='{') c2o++;
    if(c=='}') c2z++;
    if(c=='[') c3o++;
    if(c==']') c3z++;
    if(c=='<') c4o++;
    if(c=='>') c4z++;
}
if(c1o==c1z and c2o==c2z and c3o==c3z and c4o==c4z){
    for(char x : s){
    	if(x=='('){
    		s1+=x;
    	}
    	if (x==')'){
    		if(s1.length()>0){
    			if (s1[s1.length() - 1]=='('){
    				s1.pop_back();
    			}
    		}		
    	}
    
    
    	if(x=='['){
    		s1+=x;
    	}
    	if (x==']'){
    		if(s1.length()>0){
    			if (s1[s1.length() - 1]=='['){
    				s1.pop_back();
    			}
    		}		
    	}
    
    
    	if(x=='<'){
    		s1+=x;
    	}
    	if (x=='>'){
    		if(s1.length()>0){
    			if (s1[s1.length() - 1]=='<'){
    				s1.pop_back();
    			}
    		}		
    	}
    
    
    	if(x=='{'){
    		s1+=x;
    	}
    	if (x=='}'){
    		if(s1.length()>0){
    			if (s1[s1.length() - 1]=='{'){
    				s1.pop_back();
    			}
    		}		
    	}
    }
    if (s1.length()==0){
    cout<<"True";
    }
    if (s1.length()!=0){
    cout<<"False";
    }
}
else{
cout<<"False";
}
return 0;
}
